package com.tiantian.judge.listener;

import com.tiantian.common.core.constant.RabbitMQConstants;
import com.tiantian.judge.service.JudgeService;
import lombok.RequiredArgsConstructor;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Component
@RequiredArgsConstructor
public class AIJudgeListener {

    private final JudgeService judgeService;

    @RabbitListener(queues = RabbitMQConstants.AI_JUDGE_QUEUE_NAME)

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = RabbitMQConstants.AI_JUDGE_QUEUE_NAME),
            exchange = @Exchange(name = RabbitMQConstants.AI_JUDGE_EXCHANGE_NAME)
    ))
    public void listenAIJudgeQueueMessage1(Long userId) {
        judgeService.aiJudge(userId);
    }

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = RabbitMQConstants.AI_JUDGE_QUEUE_NAME),
            exchange = @Exchange(name = RabbitMQConstants.AI_JUDGE_EXCHANGE_NAME)
    ))
    public void listenAIJudgeQueueMessage2(Long userId) {
        judgeService.aiJudge(userId);
    }
}